10 REM The IBM Personal Computer star trek
15 REM Version 1.00 January 1982
20 REM Author -Dave Morrison Unionville
25 DEF SEG: POKE 106,0
30 KEY OFF:SCREEN 0,1:COLOR 15,0,0:WIDTH 40:CLS:LOCATE 5,19:PRINT "IBM"
35 LOCATE 7,12,0:PRINT "Personal Computer"
40 COLOR 10,0:LOCATE 10,9,0:PRINT CHR$(213)+STRING$(21,205)+CHR$(184)
45 LOCATE 11,9,0:PRINT CHR$(179)+"  ** STAR TREK **    "+CHR$(179)
50 LOCATE 12,9,0:PRINT CHR$(179)+STRING$(21,32)+CHR$(179)
55 LOCATE 13,9,0:PRINT CHR$(179)+"    Version 1.00     "+CHR$(179)
60 LOCATE 14,9,0:PRINT CHR$(212)+STRING$(21,205)+CHR$(190)
62 LOCATE 17,7,0:PRINT "      Dave Morrison 1982"
63 LOCATE 20,5,0:PRINT "**Trademark of Paramont Pictures"
65 COLOR 14,0:LOCATE 23,7,0:PRINT "Press space bar to continue"
70 IF INKEY$ <> "" THEN GOTO 70
75 CMD$ = INKEY$
80 IF CMD$ = " " THEN GOTO 97
85 IF CMD$ =CHR$(27) THEN END
90 GOTO 75
97 Z$=STRING$(8,32)
100 DIM G(8,8),C(9,2),K(3,3),N(3),Z(8,8),D(8)
105 CLS:Y$=TIME$
106 RANDOMIZE(INT(VAL(RIGHT$(Y$,4))))
110 T=INT(RND(1)*20+20)*100:T0=T:T9=25+INT(RND(1)*10):D0=0:E=3000:E0=E
120 P=10:P0=P:S9=200:B9=0:K9=0:X$="":X0$=" IS "
130 DEF FND(D)=SQR((K(I,1)-S1)^2+(K(I,2)-S2)^2)
140 DEF FNR(R)=INT(RND(R)*7.98+1.01)
490 Q1=FNR(1):Q2=FNR(1):S1=FNR(1):S2=FNR(1)
530 FOR I=1 TO 9:C(I,1)=0:C(I,2)=0:NEXT I
540 C(3,1)=-1:C(2,1)=-1:C(4,1)=-1:C(4,2)=-1:C(5,2)=-1:C(6,2)=-1
600 C(1,2)=1:C(2,2)=1:C(6,1)=1:C(7,1)=1:C(8,1)=1:C(8,2)=1:C(9,2)=1
670 FOR I=1 TO 8:D(I)=0:NEXT I
710 A1$="NAVSRSLRSPHATORSHEDAMCOMXXX'
750 SCREEN 1,0
820 FOR I=1 TO 8:FOR J=1 TO 8:K3=0:Z(I,J)=0:R1=RND(1)
830 XD=INT(RND*320):YD=INT(RND*200):COL=INT(RND*2):RD=INT(RND*3):PAL=INT(RND*4):HZ=INT(RND*1000+37):COLOR 0,COL:CIRCLE (XD,YD),RD,PAL:SOUND HZ,1
850 IF R1>.9799999 THEN  K3=3:K9=K9+3:GOTO 980
860 IF R1>.95 THEN K3=2:K9=K9+2:GOTO 980
870 IF R1>.8 THEN K3=1:K9=K9+1
980 B3=0:IF RND(1)>.96 THEN B3=1:B9=B9+1
1040 G(I,J)=K3*100+B3*10+FNR(1):NEXT J:NEXT I:IF K9>T9 THEN T9=K9+1
1100 IF B9<>0 THEN 1200
1150 IF G(Q1,Q2)<200 THEN G(Q1,Q2)=G(Q1,Q2)+100:K9=K9+1
1160 B9=1:G(Q1,Q2)=G(Q1,Q2)+10:Q1=FNR(1):Q2=FNR(1)
1200 K7=K9:IF B9<>1 THEN X$="S":X0$=" ARE "
1225 SCREEN 0,1:COLOR 14,0
1230 PRINT " YOUR ORDERS ARE AS FOLLOWS :"
1240 PRINT " DESTROY THE ";K9;" KLINGON WARSHIPS WHICH HAVE INVADED "
1250 PRINT " THE GALAXY BEFORE THEY CAN ATTACK FEDERATION HEADQUARTERS "
1260 PRINT " ON STARDATE ";T0+T9;"   THIS GIVES YOU ";T9;" DAYS."
1270 PRINT " THERE";X0$;B9;" STARBASE";X$;" IN THE GALAXY FOR RESUPPLYING YOUR SHIP "
1280 PRINT:PRINT " HIT SPACE BAR WHEN YOU ARE READY TO ACCEPT COMMAND "
1300 I=RND(1):IF INKEY$<>"" THEN GOTO 1300
1303 CMD$=INKEY$
1305 IF CMD$=" " THEN GOTO 1320
1310 IF CMD$=CHR$(27) THEN END
1315 GOTO 1303
1320 CLS:Z4=Q1:Z5=Q2:K3=0:B3=0:S3=0:G5=0:D4=.5*RND(1):Z(Q1,Q2)=G(Q1,Q2)
1390 IF Q1<1 OR Q1>8 OR Q2<1 OR Q2>8 THEN 1600
1430 GOSUB 9030:PRINT :IF T0<>T THEN 1490
1460 PRINT " YOUR MISSION BEGINS WITH YOUR STARSHIP LOCATED "
1470 PRINT " IN THE GALACTIC QUADRANT,";G2$;"'.":GOTO 1500
1490 PRINT " NOW ENTERING ";G2$;" QUADRANT * * * "
1500 PRINT :K3=INT(G(Q1,Q2)*.01):B3=INT(G(Q1,Q2)*.1)-10*K3
1540 S3=G(Q1,Q2)-100*K3-10*B3:IF K3=0 THEN GOTO 1590
1560 COLOR 12,0:PRINT " COMBAT AREA *** CONDITION RED":FOR JP=1 TO 4:PLAY "mbl64t120o1;cc#dd#eff#gg#aa#b":NEXT JP:IF S>200 THEN 1590
1580 COLOR 14,0:PRINT " SHIELDS DANGEROUSLY LOW"
1590 FOR I=1 TO 3:K(I,1)=0:K(I,2)=0:NEXT I
1600 FOR I=1 TO 3:K(I,3)=0:NEXT I:Q$=Z$+Z$+Z$+Z$+Z$+Z$+Z$+LEFT$(Z$,8)
1680 A$=CHR$(15):Z1=S1:Z2=S2:GOSUB 8670:IF K3<1 THEN 1820
1720 FOR I=1 TO K3:GOSUB 8590:A$=CHR$(18):Z1=R1:Z2=R2
1780 GOSUB 8670:K(I,1)=R1:K(I,2)=R2:K(I,3)=S9*(.5+RND(I)):NEXT I
1820 IF B3<1 THEN 1910
1880 GOSUB 8590:A$=CHR$(233):Z1=R1:B4=R1:Z2=R2:B5=R2:GOSUB 8670
1910 FOR I=1 TO S3:GOSUB 8590:A$=CHR$(42):Z1=R1:Z2=R2:GOSUB 8670:NEXT I
1980 GOSUB 6430
1990 L=3:IF S+E>10 THEN  IF E>10 OR D(7)=0 THEN 2060
2020 PRINT :COLOR 4,0:PRINT "***FATAL ERROR*** YOU'VE JUST STRANDED YOUR SHIP IN "
2030 PRINT "SPACE ":PRINT " YOU HAVE INSUFFICIENT MANEUVERING ENERGY,";
2040 PRINT " AND SHIELD CONTROL ":PRINT " IS PRESENTLY INCAPABLE OF CROSS";
2050 PRINT "-CIRCUITING TO ENGINE ROOM!!":GOTO 6270
2060 LOCATE 1,1,1:COLOR 23,0:B$="   ":LINE INPUT " COMMAND?";B$:COLOR 7,0
2065 FOR II=1 TO 13:LOCATE II,1,1:PRINT SPC(39):NEXT II:LOCATE 1,1,1
2080 FOR I=1 TO 9 :IF LEFT$(B$,3)<>MID$(A1$,3*I-2,3) THEN 2160
2140 ON I GOTO 2300,1980,4000,4260,4700,5530,5690,7290,6270
2160 NEXT I:LOCATE 2,1,1:COLOR 2,0:PRINT " ENTER ONE OF THE FOLLOWING:"
2180 PRINT " NAV-TO SET COURSE "
2190 PRINT " SRS-FOR SHORT RANGE SENSOR SCAN"
2200 PRINT " LRS-FOR LONG RANGE SENSOR SCAN"
2210 PRINT " PHA-TO FIRE PHASERS "
2220 PRINT " TOR-TO FIRE PHOTON TORPEDOES"
2230 PRINT " SHE-TO RAISE OR LOWER SHIELDS"
2240 PRINT " DAM-FOR DAMAGE CONTROL REPORTS"
2250 PRINT " COM-TO CALL ON LIBRARY COMPUTER"
2260 PRINT " XXX-TO RESIGN YOUR COMMAND":GOTO 1990
2300 LOCATE 2,1,1:COLOR 7,0:INPUT " COURSE (0-9)";C1:IF C1=9 THEN C1=1
2310 IF C1>=1 AND C1<9 THEN  2350
2330 PRINT " LT.SULU REPORTS INCORRECT DATA!":GOTO 1990
2350 X$="8":IF D(1)<0 THEN  X$="0.2"
2360 PRINT " WARP FACTOR (0-";X$;")";:INPUT W1:IF D(1)<0 AND W1>.2 THEN  2470
2380 IF W1>0 AND W1<=8 THEN 2490
2390 IF W1=0 THEN 1990
2420 PRINT " CHIEF ENGINEER SCOTT REPORTS THE ENGINES WON'T TAKE";
2430 PRINT " WARP ";W1;"!":GOTO 1990
2470 PRINT " WARP ENGINES ARE DAMAGED.MAXIMUM SPEED=WARP 0.2":GOTO 1990
2490 N=INT(W1*8+.5):IF E-N>0 THEN  2590
2500 PRINT " ENGINEERING REPORTS-INSUFFICIENT ENERGY AVAILABLE";
2510 PRINT " FOR MANEUVERING AT WARP";W1;"!"
2530 IF S<N-E OR D(7)<0 THEN 1990
2550 PRINT " DEFLECTOR CONTROL ROOM ACKNOWLEDGES";S;" UNITS OF ENERGY";
2560 PRINT " PRESENTLY DEPLOYED TO SHIELDS."
2570 GOTO 1990
2590 FOR I=1 TO K3:IF K(I,3)=0 THEN 2700
2610 A$=" ":Z1=K(I,1):Z2=K(I,2):GOSUB 8670:GOSUB 8590
2660 K(I,1)=Z1:K(I,2)=Z2:A$=CHR$(18):GOSUB 8670
2700 NEXT I:GOSUB 6000:D1=0:D6=W1:IF W1=>1 THEN D6=1
2770 FOR I=1 TO 8:IF D(I)>=0 THEN 2880
2790 D(I)=D(I)+D6:IF D(I)>-.1 AND D(I)<0 THEN D(I)=-.1:GOTO 2880
2800 IF D(I)<0 THEN 2880
2810 IF D1<>1 THEN  D1=1:COLOR 14,0:PRINT " DAMAGE CONTROL REPORT: "
2840 PRINT TAB(8);:R1=I:GOSUB 8790:PRINT G2$;" REPAIR COMPLETED":GOSUB 9600
2880 NEXT I:GOSUB 9650:IF RND(I)>.2 THEN 3070
2910 R1=FNR(1):IF RND(I)>=.6 THEN 3000
2930 D(R1)=D(R1)-(RND(I)*5+1):COLOR 14,0:PRINT " DAMAGE CONTROL REPORT: ";
2960 GOSUB 8790:PRINT G2$;" DAMAGED":PRINT :GOSUB 9600:GOTO 3070
3000 D(R1)=D(R1)+RND(I)*3+1:PRINT " DAMAGE CONTROL REPORT:  ";
3030 GOSUB 8790:PRINT G2$;" STATE OF REPAIR IMPROVED":GOSUB 9600
3060 'BEGIN MOVING THE STARSHIP   10
3070 A$=" ":Z1=INT(S1):Z2=INT(S2):GOSUB 8670
3110 X1=C(INT(C1),1)+(C(INT(C1+1),1))*(C1-INT(C1)):X=S1:Y=S2
3140 X2=C(INT(C1),2)+(C(INT(C1+1),2))*(C1-INT(C1)):Q4=Q1:Q5=Q2
3170 FOR I=1 TO N:S1=S1+X1:S2=S2+X2:IF S1<1 OR S1>=9 OR S2<1 OR S2>=9 THEN 3500
3240 S8=INT(S1)*8+INT(S2)-8:IF MID$(Q$,S8,1)=" " THEN 3360
3320 S1=INT(S1-X1):S2=INT(S2-X2):PRINT " WARP ENGINES SHUT DOWN AT ";
3350 PRINT "SECTOR";S1;","S2;" DUE TO BAD NAVIGATION":GOTO 3370
3360 NEXT I:S1=INT(S1):S2=INT(S2)
3370 A$=CHR$(15):Z1=INT(S1):Z2=INT(S2):GOSUB 8670:GOSUB 3910:T8=1
3430 IF W1<1 THEN T8=.1*INT(10*W1)
3450 T=T+T8:IF T>T0+T9 THEN 6220
3470 ' SEE IF DOCKED,THEN COMMAND
3480 GOTO 1980
3490 ' QUADRANT EXCEEDS LIMITS
3500 X=8*Q1+X+N*X1:Y=8*Q2+Y+N*X2:Q1=INT(X/8):Q2=INT(Y/8):S1=INT(X-Q1*8)
3550 S2=INT(Y-Q2*8):IF S1=0 THEN Q1=Q1-1:S1=8
3590 IF S2=0 THEN Q2=Q2-1:S2=8
3620 X5=0:IF Q1<1 THEN X5=1:Q1=1:S1=1
3670 IF Q1>8 THEN X5=1:Q1=8:S1=8
3710 IF Q2<1 THEN X5=1:Q2=1:S2=1
3750 IF Q2>8 THEN X5=1:Q2=8:S2=8
3790 IF X5=0 THEN 3860
3800 LOCATE 2,1,1:PRINT " LT.UHURA REPORTS MESSAGE FROM STARFLEET COMMAND:"
3810 PRINT " PERMISSION TO ATTEMPT CROSSING OF GALACTIC PERIMETER"
3820 PRINT " IS HEREBY *DENIED*.SHUT DOWN YOUR ENGINES"
3830 PRINT " CHIEF ENGINEER SCOTT REPORTS WARP ENGINES SHUT DOWN"
3840 PRINT " AT SECTOR";S1;",";S2;"OF QUADRANT";Q1;",";Q2
3850 IF T>T0+T9 THEN 6220
3860 IF 8*Q1+Q2=8*Q4+Q5 THEN 3370
3870 T=T+1:GOSUB 3910:GOTO 1320
3900 ' MANEUVER ENERGY S/R **
3910 E=E-N-10:IF E>0 THEN RETURN
3930 LOCATE 2,1,1:PRINT " SHIELD CONTROL SUPPLIES ENERGY TO COMPLETE THE MANEUVER"
3940 S=S+E:E=0:IF S<=0 THEN S=0
3980 RETURN
3990 ' LONG RANGE SENSOR SCAN CODE
4000 IF D(3)<0 THEN LOCATE 2,1,1:PRINT " LONG RANGE SENSORS INOPERABLE":GOTO 1990
4030 LOCATE 2,1,1:PRINT " LONG RANGE SCAN FOR QUADRANT";Q1;",";Q2
4040 LOCATE 3,1,1:COLOR 14,0:O1$=CHR$(213)+STRING$(15,205)+CHR$(184):PRINT " ";O1$
4060 FOR I=Q1-1 TO Q1+1:N(1)=-1:N(2)=-2:N(3)=-3:FOR J=Q2-1 TO Q2+1
4120 IF I>0 AND I<9 AND J>0 AND J<9 THEN N(J-Q2+2)=G(I,J):Z(I,J)=G(I,J)
4180 NEXT J:PRINT " ";:FOR L=1 TO 3:PRINT CHR$(179)+" ";:IF N(L)<0 THEN PRINT "***";:GOTO 4230
4210 PRINT RIGHT$(STR$(N(L)+1000),3);
4230 NEXT L:PRINT " "+ CHR$(179):PRINT " "+CHR$(198)+STRING$(15,205)+CHR$(181):NEXT I:GOTO 1990
4250 ' PHASER CONTROL
4260 LOCATE 2,1,1:IF D(4)<0 THEN PRINT " PHASERS INOPERATIVE":GOTO 1990
4265 IF K3>0 THEN 4330
4270 PRINT " SCIENCE OFFICER SPOCK REPORTS SENSORS SHOW NO ENEMY SHIPS IN THIS QUADRANT":GOTO 1990
4330 IF D(8)<0 THEN PRINT " COMPUTER FAILURE HAMPERS ACCURACY"
4350 PRINT " PHASERS LOCKED ON TARGET;  ";
4360 PRINT " ENERGY AVAILABLE=";E;"UNITS"
4370 INPUT " NUMBER OF UNITS TO FIRE";X:IF X<=0 THEN 1990
4400 IF E-X<0 THEN 4360
4405 FOR J=2 TO 6:FOR I=1 TO 2:PLAY "mbl64t255o=j;cc#dd#eff#gg#aa#b":NEXT I:NEXT J
4410 E=E-X:IF D(7)<0 THEN X=X*RND(X)
4450 H1=INT(X/K3):FOR I=1 TO 3:IF K(I,3)<=0 THEN 4670
4480 H=INT((H1/FND(0))*(RND(J)+2)):IF H>.15*K(I,3) THEN 4530
4500 PRINT " SENSORS SHOW NO DAMAGE TO ENEMY AT";K(I,1);",";K(I,2):GOTO 4670
4530 K(I,3)=K(I,3)-H:PRINT H;"UNIT HIT ON KLINGON:SECTOR";K(I,1);",";K(I,2)
4550 IF K(I,3)<=0 THEN PRINT " ***KLINGON DESTROYED***":GOTO 4580
4560 PRINT " SENSORS SHOW";K(I,3);"UNITS REMAINING":GOTO 4670
4580 K3=K3-1:K9=K9-1:Z1=K(I,1):Z2=K(I,2):A$=" ":GOSUB 8670
4650 K(I,3)=0:G(Q1,Q2)=G(Q1,Q2)-100:Z(Q1,Q2)=G(Q1,Q2):IF K9<=0 THEN 6370
4670 NEXT I:GOSUB 6000:GOSUB 6430:GOTO 1990
4690 ' PHOTON TORPEDO FIRING
4700 IF P<=0 THEN LOCATE 2,1,1:COLOR 7,0:PRINT " ALL PHOTON TORPEDOES EXPENDED":GOTO 1990
4730 IF D(5)<0 THEN LOCATE 2,1,1:COLOR 7,0:PRINT " PHOTON TUBES ARE NOT OPERATIONAL":GOTO 1990
4760 LOCATE 2,1,1:COLOR 7,0:INPUT " PHOTON TORPEDO COURSE (1-9)";C1:IF C1=9 THEN C1=1
4780 IF C1>=1 AND C1<9 THEN 4830
4790 PRINT " ENSIGN CHEKOV REPORTS INCORRECT COURSE DATA!"
4800 GOTO 1990
4830 GOTO 4850:IF C1>8 THEN C1=C1-8
4850 X1=C(INT(C1),1)+(C(INT(C1+1),1)-C(INT(C1),1))*(C1-INT(C1)):E=E-2:P=P-1
4860 X2=C(INT(C1),2)+(C(INT(C1+1),2)-C(INT(C1),2))*(C1-INT(C1)):X=S1:Y=S2
4870 TP1=0
4910 PRINT " TORPEDO TRACK:"
4915 TP=0
4920 X=X+X1:Y=Y+X2:X3=INT(ABS(X)+.5):Y3=INT(Y+.5):PLAY "MBO2BA"
4950 IF TP=0 THEN XT=X3:YT=Y3:TP=1
4960 IF X3<1 OR X3>8 OR Y3<1 OR Y3>8 THEN IF TP1=1 THEN Z1=XT:Z2=YT:A$=" ":GOSUB 8670:LOCATE 3,1,1:GOTO 5490 ELSE 5490
5000 A$=" ":Z1=X:Z2=Y:GOSUB 8830
5010 TP1=1
5050 IF Z3<>0 THEN A$=" ":Z1=XT:Z2=YT:GOSUB 8670:A$=CHR$(248):TP=2:Z1=X3:Z2=Y3:GOSUB 8670:XT=X3:YT=Y3:GOSUB 6430:GOTO 4920
5055 LOCATE 3,1,1:IF TP=2 THEN A$=" ":Z1=XT:Z2=YT:GOSUB 8670
5060 A$=CHR$(18):Z1=X:Z2=Y:GOSUB 8830:IF Z3=0 THEN 5210
5110 PRINT " ***KLINGON DESTROYED***":K3=K3-1:K9=K9-1:IF K9<=0 THEN 6370
5150 FOR I=1 TO 3:IF X3=K(I,1) AND Y3=K(I,2) THEN 5190
5180 NEXT I:I=3
5190 K(I,3)=0:GOTO 5430
5210 A$="*":Z1=X:Z2=Y:GOSUB 8830:IF Z3=0 THEN 5280
5260 PRINT " STAR AT";X3;",";Y3;"ABSORBED TORPEDO ENERGY":GOSUB 6000:GOTO 1990
5280 A$=CHR$(233):Z1=X:Z2=Y:GOSUB 8830:IF Z3=0 THEN 4760
5330 PRINT " ***STARBASE DETROYED***":B3=B3-1:B9=B9-1
5360 IF B9>0 OR K9>T-T0-T9 THEN 5400
5380 PRINT " AND SENTENCED TO 99 STARDATES HARD LABOUR ON CYGNUS 12!!"
5390 GOTO 6270
5400 LOCATE 2,1,1:COLOR 14,0:PRINT " STARFLEET COMMAND REVIEWING YOUR RECORD TO CONSIDER"
5410 PRINT " COURT MARTIAL!":D0=0
5430 Z1=X:Z2=Y:A$=" ":GOSUB 8670:GOSUB 6430
5435 Z1=X:Z2=Y:A$=" ":GOSUB 8670:GOSUB 6430
5470 G(Q1,Q2)=K3*100+B3*10+S3:Z(Q1,Q2)=G(Q1,Q2):GOSUB 6000:GOTO 1990
5490 PRINT " TORPEDO MISSED":GOSUB 6000:GOTO 1990
5520 ' SHIELD CONTROL
5530 IF D(7)<0 THEN LOCATE 2,1,1:PRINT " SHIELD CONTROL INOPERABLE":GOTO 1990
5560 LOCATE 2,1,1:PRINT " ENERGY AVAILABLE=";E+S:INPUT " NUMBER OF UNITS TO SHIELDS";X
5580 IF X<0 OR S=X THEN PRINT " <SHIELDS UNCHANGED>":GOTO 1990
5590 IF X<=E+S THEN 5630
5600 PRINT " THIS IS NOT THE FEDERATION TREASURY"
5610 PRINT " <SHIELDS UNCHANGED>":GOTO 1990
5630 E=E+S-X:S=X:PRINT " DEFLECTOR CONTROL REPORT:"
5660 PRINT " SHIELDS NOW AT";INT(S);"UNITS":GOTO 1990
5680 'DAMAGE CONTROL
5690 IF D(6)>=0 THEN 5910
5700 LOCATE 2,1,1:PRINT " DAMAGE CONTROL REPORT NOT AVAILABLE":IF D0=0 THEN 1990
5720 D3=0:FOR I=1 TO 8:IF D(I)<0 THEN D3=D3+.1
5760 NEXT I:IF D3=0 THEN 1990
5780 LOCATE 2,1,1:PRINT :D3=D3+D4:IF D3>=1 THEN D3=.9000001
5810 PRINT " TECHNICIANS STANDING BY TO REPAIR YOUR SHIP"
5820 PRINT " ESTIMATED REPAIR TIME:";.01*INT(100*D3);"STARDATES"
5830 INPUT " WILL YOU AUTORIZE REPAIR ORDER(Y/N)";A$
5860 IF A$<>"Y" THEN 1990
5865 FOR JC=1 TO 6:LOCATE JC,1,1:PRINT SPC(39):NEXT JC
5870 FOR I=1 TO 8:IF D(I)<0 THEN D(I)=0
5890 NEXT I:T=T+D3+.1:L=4
5895 GOTO 5912
5910 IF D0=0 THEN 5912 ELSE 5720
5912 LOCATE L,1,1:COLOR 14,0:PRINT " DEVICE         STATE OF REPAIR":FOR R1=1 TO 8
5915 S$=SPACE$(39)
5920 GOSUB 8790:PRINT G2$;LEFT$(S$,25-LEN(G2$));INT(D(R1)*100)*.01
5950 NEXT R1
5980 GOTO 1990
5990 ' KLINGONS SHOOTING
6000 IF K3<=0 THEN  RETURN
6010 IF D0<>0 THEN PRINT " STARBASE SHIELDS PROTECT THE ENTERPRISE":RETURN
6040 FOR I=1 TO 3:IF K(I,3)<=0 THEN 6200
6060 H=INT((K(I,3)/FND(1))*(2+RND(I))):S=S-H:K(I,3)=K(I,3)/(3+RND(J))
6080 COLOR 4,0:PRINT H;" UNIT HIT FROM SECTOR";K(I,1);",";K(I,2):COLOR 7,0
6090 IF S<=0 THEN 6240
6100 PRINT " <SHIELDS DOWN TO";S;"UNITS>":IF H<20 THEN 6200
6120 IF RND(I)>.6 OR H/S<=.02 THEN 6200
6140 R1=FNR(1):D(R1)=D(R1)-H/S-.5*RND(I):GOSUB 8790
6170 COLOR 14,0:PRINT " DAMAGE CONTROL REPORTS:";G2$;" DAMAGED BY HIT":GOSUB 9600
6200 NEXT I:RETURN
6210 ' END OF GAME
6220 CLS:LOCATE 1,1,1
6230 COLOR 14,0:PRINT " IT IS STARDATE";T:GOTO 6270
6240 CLS:LOCATE 1,1,1:PRINT " THE ENTERPRISE HAS BEEN DESTROYED. THE FEDERATION WILL BE CONQUERED":GOTO 6230
6270 PRINT " THERE WERE";K9;"KLINGON BATTLE CRUISERS LEFT AT THE END OF YOUR MISSION"
6290 PRINT :PRINT :IF B9=0 THEN 6360
6310 PRINT " THE FEDERATION IS IN NEED OF A NEW STARSHIP COMMANDER"
6320 PRINT " FOR A SIMILAR MISSION--IF THERE IS A VOLUNTEER,"
6330 LINE INPUT "LET HIM STEP FORWARD AND ENTER 'AYE'";A$:IF A$="AYE" THEN 105
6360 END
6370 CLS:LOCATE 1,1,1:COLOR 0,9:PRINT " CONGRATULATIONS CAPTAIN! THE LAST KLINGON BATTLE CRUISER MENACING THE FEDERATION HAS BEEN DESTROYED":PRINT
6400 PRINT " YOUR EFFICIENCY RATING IS";1000*(K7/(T-T0))^2:GOTO 6290
6420 ' SHORT RANGE SCAN AND STARTUP
6430 FOR I=S1-1 TO S1+1:FOR J=S2-1 TO S2+1
6450 IF INT(I+.5)<1 OR INT(I+.5)>8 OR INT(J+.5)<1 OR INT(J+.5)>8 THEN 6540
6490 A$=CHR$(233):Z1=I:Z2=J:GOSUB 8830:IF Z3=1 THEN 6580
6540 NEXT J:NEXT I:D0=0:GOTO 6650
6580 D0=1:COL=7:C$="DOCKED":E=E0:P=P0
6620 PRINT "SHIELDS DROPPED FOR DOCKING PURPOSES":S=0:GOTO 6720
6650 IF K3>0 THEN C$="*RED*":COL=20:GOTO 6720
6660 C$="GREEN":COL=2:IF E<E0*.1 THEN C$="YELLOW":COL=14
6720 IF D(2)>=0 THEN 6770
6730 LOCATE 14,1,0 :PRINT " ***SHORT RANGE SCANNERS ARE OUT***":RETURN
6770 O1$=" "+CHR$(213)+STRING$(16,205)+CHR$(184):LOCATE 14,1,0:COLOR 2,0:PRINT O1$+STRING$(14,32):FOR I=1 TO 8
6780 PRINT " "+CHR$(179);
6820 FOR J=(I-1)*8+1 TO (I-1)*8+8:PRINT " ";MID$(Q$,J,1);:NEXT J
6830 ON I GOTO 6850,6900,6960,7020,7070,7120,7180,7240
6850 PRINT CHR$(179)+" STARDATE   ";INT(T*10)*.1:GOTO 7260
6900 PRINT CHR$(179)+" CONDITION    ";:COLOR COL,0:PRINT C$:COLOR 2,0:GOTO 7260
6960 PRINT CHR$(179)+" QUADRANT    ";Q1;",";Q2:GOTO 7260
7020 PRINT CHR$(179)+" SECTOR      ";S1;",";S2:GOTO 7260
7070 PRINT CHR$(179)+" TORPEDOES    ";INT(P):GOTO 7260
7120 PRINT CHR$(179)+" TOTAL ENERGY ";INT(E+S):GOTO 7260
7180 PRINT CHR$(179)+" SHIELDS      ";INT(S):GOTO 7260
7240 PRINT CHR$(179)+" KLINGONS LEFT";INT(K9)
7260 NEXT I:O2$=" "+CHR$(212)+STRING$(16,205)+CHR$(190):PRINT O2$:LOCATE 2,1,1:RETURN
7280 ' LIBRARY COMPUTER
7290 IF D(8)<0 THEN LOCATE 2,1,1:COLOR 14,0:PRINT " COMPUTER DISABLED":GOTO 1990
7310 CLS
7320 L=8:LOCATE 2,1,1:COLOR 14,0:INPUT " COMPUTER ACTIVE - AWAITING COMMAND";A:IF A<0 THEN COLOR 2,0:CLS:GOTO 1990
7345 IF A>5 THEN 7360
7350 LOCATE 2,1,1:COLOR 2,0:H8=1:ON A+1 GOTO 7540,7900,8070,8500,8150,7400
7360 PRINT " FUNCTIONS AVAILABLE FROM LIBRARY COMPUTER:"
7370 PRINT "    0=CUMULATIVE GALACTIC RECORD"
7372 PRINT "    1=STATUS REPORT"
7374 PRINT "    2=PHOTON TORPEDO DATA"
7376 PRINT "    3=STARBASE NAV DATA"
7378 PRINT "    4=DIRECTION/DISTANCE CALCULATOR"
7380 PRINT "    5=GALAXY REGION NAME MAP":GOTO 7320
7390 'SET UP TO CHANGE GAL RECORD TO MAP
7400 CLS:H8=0:G5=1:LOCATE 1,1,1:PRINT "       THE GALAXY:GOTO 7550
7530 ' CUM GALACTIC RECORD
7540 PRINT " IF YOU WANT HARD COPY USE PrtSc KEY"
7543 CLS
7544 LOCATE 2,1,1:PRINT " RECORD FOR GALACTIC QUADRANT";Q1;",";Q2
7546 PRINT
7550 PRINT "   1   2   3   4   5   6   7   8 "
7560 O1$=STRING$(34,205)
7570 PRINT O1$:FOR I=1 TO 8:PRINT USING "#";I;:IF H8=0 THEN 7740
7630 FOR J=1 TO 8:PRINT CHR$(179);:IF Z(I,J)=0 THEN PRINT "***";:GOTO 7720
7700 PRINT RIGHT$(STR$(Z(I,J)+1000),3);
7720 NEXT J:GOTO 7850
7740 Z4=I:Z5=1:GOSUB 9030:J0=INT(10-.5*LEN(G2$)):PRINT TAB(J0);G2$;
7800 Z5=5:GOSUB 9030:J0=INT(26-.5*LEN(G2$)):PRINT TAB(J0);G2$;
7850 PRINT O1$:NEXT I:GOTO 1990
7890 'STATUS REPORT
7900 CLS:LOCATE 2,1,1:PRINT "   STATUS REPORT:":X$="":IF K9>1 THEN X$="S"
7940 PRINT :PRINT " KLINGON";X$;" LEFT: ";K9
7960 PRINT " MISSION COMPLETION IN";:PRINT USING "###";.1*INT((T0+T9-T)*10);:PRINT " STARDATES"
7970 X$="S":IF B9<2 THEN X$="":IF B9<1 THEN 8010
7980 PRINT " THERE ARE";B9;"STARBASE";X$
7990 GOTO 5690
8010 PRINT " YOUR STUPIDITY HAS LEFT YOU ALONE IN THE GALAXY--YOU HAVE NO STARBASES LEFT":GOTO 5690
8060 ' TOPEDOE,BASE NAV,D/D CALCULATOR
8070 IF K3<=0 THEN 4270
8080 X$="":IF K3>1 THEN X$="S"
8090 LOCATE 3,1,1:PRINT " FROM ENTERPRISE TO KLINGON CRUISER";X$;": "
8100 H8=0:FOR I=1 TO 3:IF K(I,3)<=0 THEN 8480
8110 W1=K(1,1):X=K(I,2)
8120 C1=S1:A=S2:GOTO 8220
8150 LOCATE 3,1,1:PRINT " DIRECTION DISTANCE CALCULATOR:"
8160 PRINT " LOCATION:QUADRANT";Q1;",";Q2;"SECTOR";S1;",";S2
8170 PRINT " PLEASE ENTER":INPUT " INITIAL COORDINATES(X,Y):";C1,A
8200 INPUT " FINAL COORDINATES(X,Y):";W1,X
8220 X=X-A:A=C1-W1:IF X<0 THEN 8350
8250 IF A<0 THEN 8410
8260 IF X>0 THEN 8280
8270 IF A=0 THEN  C1=5:GOTO 8290
8280 C1=1
8290 IF ABS(A)<=ABS(X) THEN 8330
8310 PRINT " DIRECTION=";C1+(((ABS(A)-ABS(X))+ABS(A))/ABS(A)):GOTO 8460
8330 PRINT " DIRECTION=";C1+(ABS(A)/ABS(X)):GOTO 8460                          LIST 8310
8350 IF A>0 THEN C1=3:GOTO 8420
8360 IF X<>0 THEN C1=5:GOTO 8290
8410 C1=7
8420 IF ABS(A)>=ABS(X) THEN 8450
8430 PRINT " DIRECTION=";C1+(((ABS(X)-ABS(A))+ABS(X))/ABS(X)):GOTO 8460
8450 PRINT " DIRECTION=";C1+(ABS(X)/ABS(A)):GOTO 8460                          LIST 8310
8460 PRINT " DISTANCE=";SQR(X^2+A^2):IF H8=1 THEN 1990
8480 NEXT I:GOTO 1990
8500 IF B3<>0 THEN LOCATE 3,1,1:PRINT " FROM ENTERPRISE TO STARBASE:":W1=B4:X=B5:GOTO 8120
8510 LOCATE 2,1,1:PRINT " MR SPOCK REPORTS-SENSORS SHOW NO STARBASES IN THIS QUADRANT":GOTO 1990
8590 R1=FNR(1):R2=FNR(2):A$=" ":Z1=R1:Z2=R2:GOSUB 8830:IF Z3=0 THEN 8590
8600 RETURN
8670 S8=INT(Z2-.5)+INT(Z1-.5)*8+1
8675 IF LEN(A$)<>1 THEN PRINT "ERROR 8675 ":STOP
8680 IF S8=1 THEN Q$=A$+RIGHT$(Q$,63):RETURN
8690 IF S8=64 THEN Q$=LEFT$(Q$,63)+A$:RETURN
8700 Q$=LEFT$(Q$,S8-1)+A$+RIGHT$(Q$,64-S8):RETURN
8790 ON R1 GOTO 8792,8794,8796,8798,8800,8802,8804,8806
8792 G2$="WARP ENGINES":RETURN
8794 G2$="SHORT RANGE SENSORS":RETURN
8796 G2$="LONG RANGE SENSORS":RETURN
8798 G2$="PHASER CONTROL":RETURN
8800 G2$="PHOTON TUBES":RETURN
8802 G2$="DAMAGE CONTROL":RETURN
8804 G2$="SHIELD CONTROL":RETURN
8806 G2$="LIBRARY COMPUTER":RETURN
8830 Z1=INT(Z1+.5):Z2=INT(Z2+.5):S8=(Z2-1)+(Z1-1)*8+1:Z3=0
8890 IF MID$(Q$,S8,1)<>A$ THEN RETURN
8900 Z3=1:RETURN
9030 IF Z5=<4 THEN  ON Z4 GOTO 9040,9050,9060,9070,9080,9090,9100,9110
9035 GOTO 9120
9040 G2$="ANTARES":GOTO 9210
9050 G2$="RIGEL":GOTO 9210
9060 G2$="PROCYON":GOTO 9210
9070 G2$="VEGA":GOTO 9210
9080 G2$="CANOPUS":GOTO 9210
9090 G2$="ALTAIR":GOTO 9210
9100 G2$="SAGITARIUS":GOTO 9210
9110 G2$="POLLUX":GOTO 9210
9120 ON Z4 GOTO 9130,9140,9150,9160,9170,9180,9190,9200
9130 G2$="SIRIUS":GOTO 9210
9140 G2$="DENEB":GOTO 9210
9150 G2$="CAPELLA":GOTO 9210
9160 G2$="BETELGEUSE":GOTO 9210
9170 G2$="ALDEBARAN":GOTO 9210
9180 G2$="REGULUS":GOTO 9210
9190 G2$="ARCTURUS":GOTO 9210
9200 G2$="SPICA":GOTO 9210
9210 IF G5<>1 THEN ON Z5 GOTO 9230,9240,9250,9260,9230,9240,9250,9260
9220 RETURN
9230 G2$=G2$+" I":RETURN
9240 G2$=G2$+" II":RETURN
9250 G2$=G2$+" III":RETURN
9260 G2$=G2$+" IV":RETURN
9600 FOR JP=1 TO 6:PLAY "mfl64t120o1;cc#dd#eff#gg#aa#b":NEXT JP:RETURN
9650 FOR JP=40 TO 200 STEP 5:SOUND JP,2:NEXT JP:RETURN
